/**
 * Created by yeso on 2015/9/24.
 */
angular.module('app.service.shop', ['ngResource'])

//shop
    .service('ShopService', ['$resource', function ($resource) {
        var resource = $resource(localhost + "shop/:shopid");
        //增加shop
        this.addshop = function (shop, success, error) {
            return resource.save({}, shop, success, error);
        }
        //通过id,获取shop
        this.getshopbyid = function (id) {
            return resource.get({shopid: id});
        }
        //通过name,获取shop
        this.getshopbyname = function (name) {
            var resource = $resource(localhost + "shop/byname/:name");
            return resource.get({name: name});
        }
    }])

//shoplist
    .service('ShopListService', ['$resource', function ($resource) {
        var resource = $resource(localhost + "shoplist/:countyid");
        //获取shoplist
        this.getshoplist = function(countyid) {
            return resource.query({countyid:countyid});
        }
    }])

//shopgroup
    .service('ShopGroupService', ['$resource', function ($resource) {
        var resource = $resource(localhost + "shop/bygroup/:groupid");
        //获取shoplist
        this.getgroupshoplist = function(groupid) {
            return resource.query({groupid:groupid});
        }
    }])
;